<?php
/*
// @author : lael
// blog : http://hi.baidu.com/lael80
// http://www.gzyd.net
// all right reserved.
*/
namespace ydsdk\core;
class admin extends \ydsdk\core\common {
	public $smarty = null;

	public function __construct(){
		parent::__construct();
		if(!$GLOBALS['YD_SDK']['libraries']['smarty']){
			$this->smarty = $this->library('smarty', $this->config['smarty']);
			$GLOBALS['YD_SDK']['libraries']['smarty'] = $this->smarty;
		}else{
			$this->smarty = $GLOBALS['YD_SDK']['libraries']['smarty'];
		}
		if(!is_dir(YD_ROOT.'data/runtime/admin/default/views'))@mkdir(YD_ROOT.'data/runtime/admin/default/views', 0777, true);
		if(!is_dir(YD_ROOT.'data/runtime/admin/default/cache'))@mkdir(YD_ROOT.'data/runtime/admin/default/views', 0777, true);
        $this->smarty->template_dir    = YD_ROOT.'theme/admin/default/views';
        $this->smarty->compile_dir     = YD_ROOT.'data/runtime/admin/default/views';
        $this->smarty->cache_dir       = YD_ROOT.'data/runtime/admin/default/cache';
		
		$this->smarty->assign('theme', YD_URL.'theme/admin/default/static');

		if(!$_SESSION['admin'] && strpos($GLOBALS['YD_SDK']['con'], 'admin/login') !== 0)redirect(array('con' => 'admin/login'));
	}
}